package com.herongo.service;

import com.herongo.controller.UserController;
import com.herongo.dao.IUserDao;
import com.herongo.entity.GoodComment;
import com.herongo.entity.GoodDetailContent;
import com.herongo.service.IUserService;
import org.junit.After;
import org.junit.Before;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.junit.Test;

import java.util.Date;

public class test {
    ClassPathXmlApplicationContext applicationContext= null;

    @Before
    public void beforeMethod(){
        String fileName  ="applicationContext.xml";
        applicationContext  = new ClassPathXmlApplicationContext(fileName);

    }
    @After
    public void  afterMethod(){
        applicationContext.close();
    }
    @Test
    public void modify(){
        IUserService userService =applicationContext.getBean(IUserService.class);
        Date date = new Date();
        userService.modifyDetailContent(new GoodDetailContent(2,41,"gfs","dsaa",date,date));
    }
    @Test
    public void query(){
        IUserService userService =applicationContext.getBean(IUserService.class);
        ///System.out.println(userService.queryContent(1));
        //System.out.println(userService.queryImg(1));
        System.out.println(userService.queryCommentList(5));
    }
    @Test
    public void addcontent(){
        IUserService userService =applicationContext.getBean(IUserService.class);
        Date date = new Date();
        System.out.println(userService.addComment(new GoodComment("gdff",1,5,date,date,5)));
    }
}
